import WordsReader from '../utils/WordsReader';
import ToolKit from '../utils/ToolKit';


export default class SurnameGenerator {

    getSurnames = (count) => {
        return new Promise((resolve, reject) => {
            WordsReader.readWords('surname.txt')
                .then((words) => {
                    const retList = [];
                    for (let i = 0; i < count; i++) {
                        const randomIndex = ToolKit.randomNumber(words.length - 1); //在长度范围内随机取数
                        retList.push(words[randomIndex]);
                    }
                    resolve(retList);
                }).catch((e) => {
                reject(e);
            });
        });
    }
}
